<?php

namespace app\home\validate;

use think\Validate;

class UrlChannel extends Validate
{

    /**
     * 规则定义
     * @var array
     */
    protected $rule = [
        'channelNum'  => ['require', 'integer', 'between' => '1,10'],
        'channelName' => ['require', 'length' => '2,50'],
        'channelKey'  => 'require|length:2,50',
        'channelCode' => 'require|length:2,50',
        'link'        => ['require', 'length' => '12,250', 'regex' => '/(http|https):\/\/([\w.]+\/?)\S*/'],
    ];

    /**
     * 提示信息定义
     * @var array
     */
    protected $message = [
        'channelNum'  => '请输入1-100之间的正整数',
        'channelName' => '请输入2-50位渠道名称',
        'channelKey'  => '请输入2-50位渠道参数key',
        'channelCode' => '请输入2-50位渠道参数值value',
        'link'        => '请输入12-250字符http或https协议原始链接',
    ];

    /**
     * 场景定义
     * @var array
     */
    public $scene = [
        'operateAjax'  => ['channelName', 'channelCode'],
        'batchAddAjax' => ['channelNum', 'channelName', 'channelKey', 'channelCode', 'link']
    ];
}